package com.guapi.gwt.reference.client;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.guapi.gwt.parser.client.model.Content;



public class ContentSummaryDisplay extends FlexTable {

	public ContentSummaryDisplay(Content content) {
		
		int col = 0;
		
		if (content.getTrailImage() != null) {
			Image image = new Image(content.getTrailImage());
			image.setWidth("140px");
			setWidget(0, col++, image);
		}
		
		VerticalPanel textPanel = new VerticalPanel();
		Label label = new Label(content.getHeadline());
		label.setStyleName("legend");
		textPanel.add(label);
		textPanel.add(new Anchor(content.getWebUrl(), content.getWebUrl()));
		textPanel.add(new Label(content.getTrailText()));
		setWidget(0, col, textPanel);
		getCellFormatter().setVerticalAlignment(0, col, HasVerticalAlignment.ALIGN_TOP);
	
	}

}
